using System;

namespace Liphofra.Core.EventAggregation
{
    /// <summary>
    /// Describes an event aggregator for loosely coupled event messaging.
    /// </summary>
    public interface IEventAggregator
    {
        /// <summary>
        /// Gets the event so a consumer can subscribe to it.
        /// </summary>
        /// <typeparam name="TEvent">The type of the event to retrieve.</typeparam>
        /// <returns>An <see cref="IObservable{TEvent}" /> of the given event type that can be used to subscribe to the event.</returns>
        IObservable<TEvent> GetEvent<TEvent>();

        /// <summary>
        /// Publishes an instance of the specified event.
        /// </summary>
        /// <typeparam name="TEvent">The type of the event.</typeparam>
        /// <param name="theEvent">The event instance to publish.</param>
        void Publish<TEvent>(TEvent theEvent);
    }
}